[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 feof()                  Detect Stream End-of-File (Macro)

 #include   <stdio.h>

 int        feof(stream);
 FILE       *stream;                     Pointer to file structure

    feof() tests 'stream' for the end-of-file indicator. If the EOF
    indicator is set, subsequent read operations will return an end-of-
    file until a call to rewind() or clearerr() is made or until 'stream'
    is closed.  feof() is a macro.

       Returns:     A non-zero value when the end-of-file has been
                    reached.  Zero is returned if the current position is
                    not end-of-file.  There is no error return.

   -------------------------------- Example ---------------------------------

    This example opens a file, prints its contents until end-of-file is
    reached, then closes the file.

           #include <stdio.h>

           FILE *stream;
           int c;

           main()
           {
               if ((stream = fopen("stat.dat","r+")) != NULL) {
                    while(!feof(stream)) {
                        c = getc(stream);
                        printf("%c",c);
                    }
                    fclose(stream);
               }
           }


See Also: eof() clearerr() ferror() perror()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson